home *** CD-ROM | disk | FTP | other *** search
- Path: alpha.fdu.edu!rich
- From: "Mr. Rich Reybok" <rich@alpha.fdu.edu>
- Newsgroups: comp.lang.c
- Subject: Memcpy Problem
- Date: Mon, 4 Mar 1996 16:34:15 -0500
- Organization: Fairleigh Dickinson University
- Message-ID: <Pine.OSF.3.91.960304161419.15251A-100000@alpha.fdu.edu>
- NNTP-Posting-Host: alpha.fdu.edu
- Mime-Version: 1.0
- Content-Type: TEXT/PLAIN; charset=US-ASCII
-
- Hi.
- I'm writing a little program using BC 4.5, and I seem to have run
- into a bit of difficulty.
- Here's the code snippet:
-
- {
- char *temp="2592000"
- long l;
- char temp2[100];
- l=atol(temp)
- memcpy(temp2,(char *)(&l),sizeof(l));
- XXX(temp2,LONG_TYPE);
- }
-
- where XXX is defined as XXX(void *value,int datatype); XXX casts value
- as datatype. This code basically creates a long value out of a char *
- that it's gets from elsewhere in the program. It should then copy the
- byte pattern of the long into a char * and send it to XXX. However I get
- a memory problem and the debugger exits with error 9. I don't know what
- error 9 was, couldn't find references to it anywhere :-( If I change l
- to an int and use atoi everything works fine. However I have one value
- that will always be a long so I need a solution. Changing XXX is
- impossible, it is in an SDK I'm using. Any suggestions? Am I
- overlooking something between the long and int data types?
-
- TIA
- -Rich
-
-
- ********************************************************************************
- Rich Reybok
- Network & Systems Analyst
- Fairleigh Dickinson University
- 10 Woodridge Ave
- Hackensack, NJ 07601
- (201) 692-2357
- Reply: rich@fdu.edu
- *******************************************************************************
-
-
-